//
//  ViewController2.m
//  核心动画代码
//
//  Created by 申元江 on 2018/7/30.
//  Copyright © 2018年 申元江. All rights reserved.
//

#import "ViewController2.h"

#define angleToRadians(angle) ((angle) / 180.0 * M_PI)

@interface ViewController2 ()
@property (weak, nonatomic) IBOutlet UIImageView *icon;

@end

@implementation ViewController2

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];
    anim.keyPath = @"transform.rotation";
    anim.values = @[@angleToRadians(-3),@angleToRadians(3),@angleToRadians(-3)];
    anim.repeatCount = MAXFLOAT;
    [self.icon.layer addAnimation:anim forKey:nil];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
